package day10;

import java.util.Random;

public class Demo01 {
    public static void main(String[] args) {
        /*
         * Java 8 接口语法
         */
        AwardType awardType = Award.random();
        System.out.println(awardType);
        Ship ship = new Ship();
        Airplane airplane = new Airplane();
        System.out.println(ship.getAward());
        System.out.println(airplane.getAward());
    }
}
enum AwardType{
    FIRE, LIFE, BOMB
}
interface Award{
    default AwardType getAward(){
        return Award.random();
    }
    static AwardType random(){
        Random random = new Random();
        AwardType[] types = AwardType.values();
        int i = random.nextInt(types.length);
        return types[i];
    }
}

class Airplane implements Award{
//    @Override
//    public AwardType getAward() {
//        return Award.random();
//    }
}

class Ship implements Award{
    @Override
    public AwardType getAward() {
        return AwardType.LIFE;
    }
}